# coding=UTF-8
# author=suemi
# created at 16/5/13


import logging.config
import os

logging.config.fileConfig("conf/logging.ini")

ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

DATA_DIR = ROOT_DIR + "/data"

INDEX_DIR = DATA_DIR

DATE_FORMAT = "%Y%m%d"

DATETIME_FORMAT = "%Y%m%d-%H:%M:%S"

ES_SETTINGS = {
    'host': 'localhost',
    'port': 9200
}

INDEX_NAME = 'pysearch_index'

INDEX_TYPE = 'article_type'

CUSTOM_MAP = {
    'boost': 1.0,
    'index': 'analyzed',
    'store': 'yes',
    'type': 'string'
    # "index_options": "offsets"  把高亮改成偏移则需要带上这一行
}

INDEX_MAPPINGS = {
    'url': {
        'store': 'yes',
        'type': 'string'
    },
    'author': {
        'store': 'yes',
        'type': 'string'
    },
    'lang': {
        'store': 'yes',
        "index": "not_analyzed",
        'type': 'string'
    },
    'title': CUSTOM_MAP,
    'content': CUSTOM_MAP,
    'tag': CUSTOM_MAP,
    'site': CUSTOM_MAP,
    'crawledAt': {
        'store': 'yes',
        "index": "not_analyzed",
        'type': 'date',
        'format': 'yyyyMMdd-HH:mm:ss'
    },
    'publishAt': {
        'store': 'yes',
        "index": "not_analyzed",
        # 'type': 'date',
        # 'format': 'yyyyMMdd-HH:mm:ss'
        'type': 'string'
    }
}

INDEX_SETTINGS = {
    "analysis": {
        "analyzer": {
            'default': {
                'type': 'smartcn'
            }
        }
    }
}
